﻿using System.Windows.Media;

namespace Red.Toolkit.Profiler.Drawing
{
    public class TimelineStyle
    {
        public System.Globalization.CultureInfo CultureInfo;
        public Typeface TextTypeface;

        public Color BackgroundColor;
        public Brush BackgroundBrush;
        public Brush RegionBrush;

        public Brush SelectionRectBrush;
        public Pen SelectionRectPen;

        public Color GroupLineColor;
        public Pen CursorPen;
        public Pen GroupLinePen;
        public Pen ViewLinePen;
        public Brush GroupNameBrush;

        public Color SelectedBlockBrushColor;
        public Brush SelectedBlockBrush;
        public Color SelectedBlockPenColor;

        public Color HighlightedBlockBrushColor;
        public Brush HighlightedBlockBrush;
        public Color HighlightedBlockPenColor;

        public int TimeBarHeight;
        public int TimeBarTickHeightSmall;

        public Color TimeBarColor;
        public Brush TimeBarBrush;
        public Pen TimeBarPen;
        public Brush TimeBarFontBrush;

        public Brush TimeBarTickBrush;
        public Pen TimeBarTickPen;

        public Brush TimeBarCurrentBrush;
        public Brush TimeBarGridBrush;
        public Brush TimeInvalidRangeBrush;
        public Brush TimeBarInvalidBrush;

        public int LevelSpacing = 0;
        public int GroupTitleSpacing = 18;
        public int ViewTitleSpacing = 20;
        public int PostGroupSpacing = 10;
        public int BlockHeight = 18;

        public double BlockMergeTreshold = 3.0;

        public TimelineStyle()
        {
            CultureInfo = System.Globalization.CultureInfo.GetCultureInfo( "en-US" );
            TextTypeface = new Typeface( "Arial" );

            BackgroundColor = Color.FromArgb( 255, 15, 15, 15 );
            BackgroundBrush = new SolidColorBrush( BackgroundColor );

            RegionBrush = new LinearGradientBrush( Color.FromArgb( 30, 255, 255, 255 ), Color.FromArgb( 0, 255, 255, 255 ), 0.0 );

            SelectionRectBrush = new SolidColorBrush( Color.FromArgb( 100, 100, 100, 255 ) );
            SelectionRectPen = new Pen( new SolidColorBrush( Color.FromArgb( 255, 100, 100, 255 ) ), 1 );

            SelectedBlockBrushColor = Color.FromArgb( 255, 80, 80, 255 );
            SelectedBlockPenColor = Color.FromArgb( 255, 80, 80, 255 );
            SelectedBlockBrush = new SolidColorBrush( SelectedBlockBrushColor );

            HighlightedBlockBrushColor = Color.FromArgb( 255, 255, 0, 0 );
            HighlightedBlockPenColor = Color.FromArgb( 255, 255, 0, 0 );
            HighlightedBlockBrush = new SolidColorBrush( HighlightedBlockBrushColor );

            CursorPen = new Pen( Brushes.White, 1 );
            GroupLineColor = Color.FromArgb( 200, 255, 255, 255 );
            GroupNameBrush = new SolidColorBrush( GroupLineColor );
            GroupLinePen = new Pen( GroupNameBrush, 1.0 );
            ViewLinePen = new Pen( GroupNameBrush, 3.0 );

            TimeBarHeight = 40;
            TimeBarTickHeightSmall = 8;

            TimeBarColor = Color.FromArgb( 200, 100, 100, 100 );
            TimeBarBrush = new SolidColorBrush( TimeBarColor );
            TimeBarPen = new Pen( TimeBarBrush, 1.0 );
            TimeBarFontBrush = new SolidColorBrush( Color.FromArgb( 170, 255, 255, 255 ) );

            TimeBarTickBrush = new SolidColorBrush( Color.FromArgb( 255, 160, 160, 160 ) );
            TimeBarTickPen = new Pen( TimeBarTickBrush, 1.0 );

            TimeBarCurrentBrush = new SolidColorBrush( Color.FromArgb( 255, 128, 255, 128 ) );
            TimeBarGridBrush = new SolidColorBrush( Color.FromArgb( 255, 240, 240, 240 ) );
            TimeInvalidRangeBrush = new SolidColorBrush( Color.FromArgb( 255, 160, 160, 160 ) );
            TimeBarInvalidBrush = new SolidColorBrush( Color.FromArgb( 255, 140, 140, 140 ) );

            FreezeAll();
        }

        private void FreezeAll()
        {
            BackgroundBrush.Freeze();
            RegionBrush.Freeze();
            SelectionRectBrush.Freeze();
            SelectionRectPen.Freeze();
            SelectedBlockBrush.Freeze();
            HighlightedBlockBrush.Freeze();
            CursorPen.Freeze();
            GroupNameBrush.Freeze();
            GroupLinePen.Freeze();
            ViewLinePen.Freeze();
            TimeBarBrush.Freeze();
            TimeBarPen.Freeze();
            TimeBarFontBrush.Freeze();
            TimeBarTickBrush.Freeze();
            TimeBarTickPen.Freeze();
            TimeBarCurrentBrush.Freeze();
            TimeBarGridBrush.Freeze();
            TimeInvalidRangeBrush.Freeze();
            TimeBarInvalidBrush.Freeze();
        }
    }
}
